﻿const TokenKey = 'token'

export function getToken() {
	const value = window.localStorage.getItem(TokenKey)
  try {
    return JSON.parse(window.localStorage.getItem(TokenKey))
  } catch (error) {
    return value
  }
}

export function setToken(token) {
	return window.localStorage.setItem(TokenKey, JSON.stringify(token))
}

export function removeToken() {
	return window.localStorage.removeItem(TokenKey)
}

export function setLocalData(data) {
	return localStorage.setItem('userInfo', JSON.stringify(data));
}
export function removeLocalData() {
	return window.localStorage.removeItem("userInfo")
}
export function getLocalData() {
	const value = window.localStorage.getItem("userInfo")
  try {
    return JSON.parse(window.localStorage.getItem("userInfo"))
  } catch (error) {
    return value
  }
}